{"ast":null,"code":"import { useForm as useRcForm } from 'rc-field-form';\nimport * as React from 'react';\nimport scrollIntoView from 'scroll-into-view-if-needed';\nimport { getFieldId, toArray } from '../util';\nfunction toNamePathStr(name) {\n  const namePath = toArray(name);\n  return namePath.join('_');\n}\nexport default function useForm(form) {\n  const [rcForm] = useRcForm();\n  const itemsRef = React.useRef({});\n  const wrapForm = React.useMemo(() => form !== null && form !== void 0 ? form : Object.assign(Object.assign({}, rcForm), {\n    __INTERNAL__: {\n      itemRef: name => node => {\n        const namePathStr = toNamePathStr(name);\n        if (node) {\n          itemsRef.current[namePathStr] = node;\n        } else {\n          delete itemsRef.current[namePathStr];\n        }\n      }\n    },\n    scrollToField: function (name) {\n      let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};\n      const namePath = toArray(name);\n      const fieldId = getFieldId(namePath, wrapForm.__INTERNAL__.name);\n      const node = fieldId ? document.getElementById(fieldId) : null;\n      if (node) {\n        scrollIntoView(node, Object.assign({\n          scrollMode: 'if-needed',\n          block: 'nearest'\n        }, options));\n      }\n    },\n    getFieldInstance: name => {\n      const namePathStr = toNamePathStr(name);\n      return itemsRef.current[namePathStr];\n    }\n  }), [form, rcForm]);\n  return [wrapForm];\n}","map":{"version":3,"names":["useForm","useRcForm","React","scrollIntoView","getFieldId","toArray","toNamePathStr","name","namePath","join","form","rcForm","itemsRef","useRef","wrapForm","useMemo","Object","assign","__INTERNAL__","itemRef","node","namePathStr","current","scrollToField","options","arguments","length","undefined","fieldId","document","getElementById","scrollMode","block","getFieldInstance"],"sources":["/data/messenger.client/node_modules/antd/es/form/hooks/useForm.js"],"sourcesContent":["import { useForm as useRcForm } from 'rc-field-form';\nimport * as React from 'react';\nimport scrollIntoView from 'scroll-into-view-if-needed';\nimport { getFieldId, toArray } from '../util';\nfunction toNamePathStr(name) {\n  const namePath = toArray(name);\n  return namePath.join('_');\n}\nexport default function useForm(form) {\n  const [rcForm] = useRcForm();\n  const itemsRef = React.useRef({});\n  const wrapForm = React.useMemo(() => form !== null && form !== void 0 ? form : Object.assign(Object.assign({}, rcForm), {\n    __INTERNAL__: {\n      itemRef: name => node => {\n        const namePathStr = toNamePathStr(name);\n        if (node) {\n          itemsRef.current[namePathStr] = node;\n        } else {\n          delete itemsRef.current[namePathStr];\n        }\n      }\n    },\n    scrollToField: function (name) {\n      let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};\n      const namePath = toArray(name);\n      const fieldId = getFieldId(namePath, wrapForm.__INTERNAL__.name);\n      const node = fieldId ? document.getElementById(fieldId) : null;\n      if (node) {\n        scrollIntoView(node, Object.assign({\n          scrollMode: 'if-needed',\n          block: 'nearest'\n        }, options));\n      }\n    },\n    getFieldInstance: name => {\n      const namePathStr = toNamePathStr(name);\n      return itemsRef.current[namePathStr];\n    }\n  }), [form, rcForm]);\n  return [wrapForm];\n}"],"mappings":"AAAA,SAASA,OAAO,IAAIC,SAAS,QAAQ,eAAe;AACpD,OAAO,KAAKC,KAAK,MAAM,OAAO;AAC9B,OAAOC,cAAc,MAAM,4BAA4B;AACvD,SAASC,UAAU,EAAEC,OAAO,QAAQ,SAAS;AAC7C,SAASC,aAAa,CAACC,IAAI,EAAE;EAC3B,MAAMC,QAAQ,GAAGH,OAAO,CAACE,IAAI,CAAC;EAC9B,OAAOC,QAAQ,CAACC,IAAI,CAAC,GAAG,CAAC;AAC3B;AACA,eAAe,SAAST,OAAO,CAACU,IAAI,EAAE;EACpC,MAAM,CAACC,MAAM,CAAC,GAAGV,SAAS,EAAE;EAC5B,MAAMW,QAAQ,GAAGV,KAAK,CAACW,MAAM,CAAC,CAAC,CAAC,CAAC;EACjC,MAAMC,QAAQ,GAAGZ,KAAK,CAACa,OAAO,CAAC,MAAML,IAAI,KAAK,IAAI,IAAIA,IAAI,KAAK,KAAK,CAAC,GAAGA,IAAI,GAAGM,MAAM,CAACC,MAAM,CAACD,MAAM,CAACC,MAAM,CAAC,CAAC,CAAC,EAAEN,MAAM,CAAC,EAAE;IACtHO,Y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